@isTest
private class  MeasureCalcSearchControllerTest {
    static testMethod void testMethod1() {
        // 客户
        Account acc = TestUtils.createAccount();
        insert acc;

        Account acc1 = TestUtils.createDealer();
        insert acc1;


        // 业务机会
        Opportunity opp = TestUtils.createOpportunity();
        opp.AccountId = acc.Id;
                opp.CooperationMode__c= '整体配送';
                opp.CoopDealer__c = acc1.Id;

        insert opp;




        // 产品
        Product__c p = TestUtils.createProduct();
        p.Purpose__c = '仪器报价用';
        Product__c p2 = TestUtils.createProduct();
        p2.Name = 'aaaa';
        p2.Purpose__c = '仪器报价用';
        insert new Product__c[] {p, p2};


        // 价格
        Price__c price = TestUtils.createPrice();
        price.Product__c = p.Id;
        price.Company__c = '四川省迈克实业有限公司';
        Price__c price2 = TestUtils.createPrice();
        price2.Product__c = p2.Id;
        price2.Company__c = '四川省迈克实业有限公司';
        insert new Price__c[] {price, price2};



        Measure_Calculate__c mc = new Measure_Calculate__c(
            Opportunity__c = opp.Id,
            Company__c='四川省迈克实业有限公司'
        );
        insert mc;

        // ---------------------新建-----------------------
        PageReference page = new PageReference('/apex/MeasureCalcSearch?id=' + mc.Id);
        System.Test.setCurrentPage(page);
        MeasureCalcSearchController qc = new MeasureCalcSearchController(new ApexPages.StandardController(mc));

        qc.init();

        qc.name = 'aaaa';
        qc.brand = '济南希森美康';
        qc.serial = 'ZG801009';
        qc.category0 = '试剂';
        qc.category1 = '临检';
        qc.search();

        System.assertEquals(1, qc.pbList.size());

       qc.pbList[0].chk = true;
       qc.getProductFromCp();
        qc.exchange();
        qc.saveAndStay();

        // ---------------------编辑-----------------------
         page = new PageReference('/apex/MeasureCalcSearch?id=' + mc.Id);
        System.Test.setCurrentPage(page);
         qc = new MeasureCalcSearchController(new ApexPages.StandardController(mc));

        qc.init();
        qc.saveAndStay();


    }
}